<script setup >
import { provide,ref } from "vue"
import Son from "./Son.vue"

const str = ref('hello');

provide('msg',str.value);

const testf = () => {
    str.value +="1";
}

</script>

<template>
    <div>
        <h1>跨级组件传值（用Provider和inject）</h1>
        <h2>父组件</h2>
        <input type="button" value="测试" @click="testf" />
        <hr/>
        <Son ref="sonRef" />
    </div>
</template>

<style lang="css" scoped>
    
</style>
